:<<!EOF!
#!/bin/bash

DIRECTORY="."  # 替换为待比较的目录路径

# 列出目录下的所有文件
files=$(ls $DIRECTORY)

# 遍历每一对文件进行比较并记录区别行数小于指定值的文件名
for file1 in $files; do
    for file2 in $files; do
        if [ "$file1" != "$file2" ]; then
            diff_count=$(diff -y --suppress-common-lines $DIRECTORY/$file1 $DIRECTORY/$file2 | wc -l)
            total_lines_file1=$(wc -l < $DIRECTORY/$file1)
            total_lines_file2=$(wc -l < $DIRECTORY/$file2)

            if [ $diff_count -lt $1 ]; then
                echo "$file1 $file2 $diff_count $total_lines_file1 $total_lines_file2"
            fi
        fi
    done
done
!EOF!

#!/bin/bash

# 检查脚本参数是否正确
if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <minimum_difference>"
    exit 1
fi

# 存储满足条件的文件记录
output_file="file_records.txt"
# 清空或创建文件记录
> "$output_file"

# 遍历目录中的文件
for file1 in *; do
    # 忽略目录和非常规文件
    if [ ! -f "$file1" ] || [ -L "$file1" ]; then
        continue
    fi

    # 获取文件1的总行数
    total_lines1=$(cat "$file1" | wc -l)

    for file2 in *; do
        # 忽略相同的文件、目录和非常规文件
        if [ "$file1" == "$file2" ] || [ ! -f "$file2" ] || [ -L "$file2" ]; then
            continue
        fi

        # 获取文件2的总行数
        total_lines2=$(cat "$file2" | wc -l)

        # 比较文件1和文件2的区别行数（忽略空行）
        diff_lines=$(diff -B --suppress-common-lines "$file1" "$file2" | wc -l)

        # 判断是否满足条件
        if [ "$diff_lines" -lt "$1" ]; then
            # 将满足条件的文件记录写入文件
            echo "$file1 $file2 $diff_lines $total_lines1 $total_lines2" >> "$output_file"
        fi
    done
done

echo "File records have been written to '$output_file'."
echo "文件比较完成！结果已记录到文件：$result_file"







































































































































333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++